using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.Serialization;

namespace CSF.Communications.Sdp.ServiceLogic.Exceptions
{
   public class SDPWSEException : SDPException
    {

        #region Private Members
        private long errorCode;
        private string message;
        #endregion Properties

        #region Properties

        /// <summary>
        /// Property to retain error code
        /// </summary>
        public long ErrorCode
        {
            get
            {
                return errorCode;
            }
        }

        /// <summary>
        /// User friendly to be set- Overriding Message propertyof base Error 
        /// </summary>
        public override string Message
        {
            get
            {
                return message;
            }
        }

        #endregion

        #region Constructors

        #region SDPWSEException
        /// <summary>
        ///   Default Constructor
        /// </summary>
        public SDPWSEException()
        {
            errorCode = (long)SDPWSEError.WSESecurityException;
            base.EventId = (int)SDPWSEEvent.WSESecurityException;
        }

        #endregion SDPWSEException

        #region SDPWSEException(string)
        /// <summary>
        /// Constructor with two parameter to convert general Exception to
        /// custom Exception UISystemException and set custom error message.
        /// </summary>
        /// <param name="description">Custom message that is to be set</param>
        public SDPWSEException(string description)
        {
            errorCode = (long)SDPWSEError.WSESecurityException;
            message = description;
            base.EventId = (int)SDPWSEEvent.WSESecurityException;
        }

        #endregion

        #region SDPWSEException(Exception)
        /// <summary>
        ///   Constructor with one parameter to convert general Exception to
        /// custom Exception UISystemException.
        /// </summary>
        /// <param name="sdpUISystemException">System Exception that is caught</param>
        public SDPWSEException(Exception sdpSystemException)
        {
            errorCode = (long)SDPWSEError.WSESecurityException;
            message = sdpSystemException.Message;
            base.EventId = (int)SDPWSEEvent.WSESecurityException;
        }

        #endregion SDPWSEException(Exception)

        #region SDPWSEException(string,Exception)
        /// <summary>
        /// Constructor with two parameter to convert general Exception to
        /// custom Exception UISystemException and set custom error message.
        /// </summary>
        /// <param name="description">Custom message that is to be set</param>
        /// <param name="sdpUISystemException">System Exception caught</param>
        public SDPWSEException(string description, Exception sdpSystemException)
        {
            errorCode = (long)SDPWSEError.WSESecurityException;
            message = description + Environment.NewLine + sdpSystemException.Message;
            base.EventId = (int)SDPWSEEvent.WSESecurityException;
        }

        #endregion

        #region SDPWSEException(long,string)
        /// <summary>
      /// Constructor with two parameter to convert general Exception to
      /// custom Exception SDPUIHEBusinessException and set custom error message.
      /// </summary>
      /// <param name="businessErrorCode">Custom error code that is to be set</param>
      /// <param name="errorDescription">Custom message that is to be set</param>
       public SDPWSEException(long businessErrorCode, string errorDescription)
      {
         errorCode = businessErrorCode;
         message = errorDescription + Environment.NewLine;

			string errorText = string.Empty;

            if (Enum.IsDefined(typeof(SDPWSEError), (SDPWSEError)errorCode))
         {
             message += ((SDPWSEError)errorCode).ToString();
             errorText = ((SDPWSEEvent)errorCode).ToString();
         }
         else
         {
             message += SDPWSEError.WSESecurityException.ToString();
             errorText = SDPWSEError.WSESecurityException.ToString();
         }
         SDPWSEEvent be = (SDPWSEEvent)Enum.Parse(typeof(SDPWSEEvent), errorText);
			base.EventId = Convert.ToInt32(be);

      }

      #endregion

        #region SDPWSEException(SerializationInfo,StreamingContext)
        /// <summary>
        /// Constructor with two parameter to convert general Exception to
        /// custom Exception UIDataException and set custom error message.
        /// </summary>
        /// <param name="SerializationInfo">SerializationInfo</param>
        /// <param name="StreamingContext">StreamingContext</param>
        // deserialization constructor
        public SDPWSEException(SerializationInfo info, StreamingContext context)
        {
        }

        #endregion
        #endregion


    }
}
